using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using CommunityToolkit.Mvvm.ComponentModel;

namespace AvaloniaApplication1.Models.DTOModel;

public partial class MqttCardModel:ObservableObject
{
    /// <summary>
    /// MQTT设备卡片模型
    /// </summary>

    /// <summary>
    /// 设备Id
    /// </summary>
    [ObservableProperty] 
    private string _deviceId =string.Empty;
    /// <summary>
    /// mqtt服务器设备地址
    /// </summary>
    [ObservableProperty] 
    
    private string _server = string.Empty;
    /// <summary>
    /// mqtt服务器端口
    /// </summary>
    [ObservableProperty] 
    private int _port = 1883;
    /// <summary>
    /// 主题
    /// </summary>
    [ObservableProperty]
    private List<MqttTopicConfig> _topics = new() ;
    /// <summary>
    /// 用户名
    /// </summary>
    [ObservableProperty] 
    private string _username=string.Empty;
    /// <summary>
    /// 密码
    /// </summary>
    [ObservableProperty] 
    private string _password=string.Empty;

    
    public MqttCardModel()
    {
        
    }
    // 添加转换为 MqttDeviceModel 的方法
    public MqttDeviceModel ToMqttDeviceModel()
    {
        return new MqttDeviceModel(
            deviceId: DeviceId,
            server: Server,
            port: Port,
            username: Username,
            password: Password,
            topics: Topics,
            isConnected: false
        ) { MqttClient = null};
    }
    
}